/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package mytest.tx.data;

import org.springframework.transaction.annotation.Transactional;

/**
 * 
 * @author zenghua233
 * @since 4.2.1
 */
public class FooServiceImpl implements FooService {

	private TxDao txDao;

	/**
	 * 点进注解可以知道，spring的事务默认隔离级别就是数据库的默认级别，MySQL为可重复读（同一个事务读取多个查询结果都是一样的）
	 */
	@Transactional
	@Override
	public void save() {
		txDao.insert();
	}

	@Transactional
	@Override
	public void update() {
		txDao.update();
		throw new RuntimeException();
	}
	
//	@Transactional
	@Override
	public void mix() {
		save();
		update();
	}

	@Override
	public void delete() {
		// TODO Auto-generated method stub
		throw new UnsupportedOperationException("Auto-generated method stub");
	}

	@Override
	public void query() {
		// TODO Auto-generated method stub
		throw new UnsupportedOperationException("Auto-generated method stub");
	}

	public void setTxDao(TxDao txDao) {
		this.txDao = txDao;
	}

}
